package main

import (
	"fmt"
	"time"
)

func main() {
	ch1 := make(chan string, 2)
	// 消费者 2秒消费一次
	go func() {
		for p := range ch1 {
			fmt.Println(p)
			time.Sleep(time.Second * 2)
		}
	}()
	// 生产者 一秒生产一次，如果chan满了，会提示
	go func() {
		for {
			if len(ch1) >= cap(ch1) {
				fmt.Println("chan_test 满了")
			}
			ch1 <- "hello"
			time.Sleep(time.Second * 1)
		}
	}()

	time.Sleep(time.Second * 10)
}
